package object;

class Cat{
	String name;
	public Cat(String name) {
		this.name = name;
	}
}

class Girl implements Cloneable{
	String name;
	int age;
	Cat cat;
	public Girl(String name, int age, Cat cat) {
		this.name = name;
		this.age = age;
		this.cat = cat;
	}
	@Override
	protected Object clone() throws CloneNotSupportedException {
		return super.clone();
	}
}

public class CloneTest {
	public static void main(String[] args) {
		Cat c = new Cat("miao");
		Girl g = new Girl("fangfang",20,c);
		
		try {
			Girl g2 = (Girl) g.clone();
			System.out.println(g2.cat);
			System.out.println(g.cat);
			
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
	}
}
